<?php

/*
 * 动态字典查询
 */

namespace Admin\Func;

class Func999010103 {

    var $db;
    var $rst;
    var $errmsg;
    var $DictCode;

    public function __construct($DictCode) {
        $this->db = new \Think\Model();
        $this->errmsg = '';
        $this->DictCode = addslashes($DictCode);
    }

    /*
     * 获取错误信息
     */

    public function getErrMsg() {
        return $this->errmsg;
    }

    /*
     * 验证
     */

    private function validate() {
        return true;
    }

    /*
     * 执行
     */

    public function execute() {
        $vflag = true;
        $OperID = I('OperID');
        if ($this->validate()) {

            $sql = <<<EOD
SELECT t.MaterialTypeID as keyid,t.MaterialTypeName as keyvalue 
  FROM t_lz_ps_materialtype T 
  WHERE 'MaterialTypeID' = '$this->DictCode' 
EOD;

            $rst = $this->db->query($sql);

            $this->rst = array();
            foreach ($rst as $row) {

                $this->rst[$row['keyid']] = $row ['keyvalue'];
            }

            if ($this->rst === false) {
                $this->errmsg = $this->db->getDbError();
                $vflag = false;
            } else {
                $vflag = true;
            }
        } else {
            $vflag = false;
        }
        return $vflag;
    }

    public function getRst() {
        return $this->rst;
    }

}
